function backform() {
	window.location.href = 'userInstitutionAdd.jsp';

}

$.ajax({
	url: 'paramTypeList',
	type: 'POST',
	data: {
		session: $.Cookie("session"),
		userId: $.Cookie("userId"),
		companyId: $.Cookie("companyId"),
		index: 0,
		page: 20

	},
	dataType: 'json',
	success: function(data) {
		if(data.errorCode == 0) {
			var institutionId = sessionStorage.getItem("institutionId") || 1;
			var param = {
				userId: $.Cookie("userId"),
				session: $.Cookie("session"),
				id: institutionId,
			}

			$.ajax({
				url: 'getOrgById',
				type: 'POST',
				data: param,
				dataType: 'json',
				success: function(data) {
					if(data.errorCode == -303) {
						alert("机构不存在！")
					} else if(data.errorCode == -6) {
						alert("登陆超时！")
						top.location.href = 'index.jsp';

					} else if(data.errorCode == 0) {
						$("#orgName").val(data.result.orgName);
						$("#orgType").text(data.result.orgType);
						$("#rorgId").val(data.result.orgId);
						$("#principal").val(data.result.principal);
						$("#phone").val(data.result.phone);
						$("#city").val(data.result.city);
						$("#province").val(data.result.province);
						$("#area").val(data.result.area);
						$("#address").val(data.result.address);

					}

				},
				error: function(err) {
					alert("连接服务器失败！请重新提交！")
					top.location.href = 'index.jsp';

				}
			});

			$.each(data.result.paramTypeList, function(i, value) {
				if(data.result.paramTypeList[i].type == "DVC_TYPE") {

				} else {
					error_tpl = '<option value="' + data.result.paramTypeList[i].id + '">' + data.result.paramTypeList[i].paramValue + '</option>"'
					$("#org").append(error_tpl)
				}

			});
		} else if(data.errorCode == -6) {
			alert("登录超时！")
			top.location.href = 'index.jsp';

		} else {
			alert("请重试！")
		}

	},
	error: function(err) {

		alert("连接服务器失败！请重新提交！")
		top.location.href = 'index.jsp';

	}
});

function formform() {
	var param = {
		session: $.Cookie("session"),
		userId: $.Cookie("userId"),
		id: sessionStorage.getItem("institutionId"),
		orgName: $("#orgName").val(),
		principal: $("#principal").val(),
		phone: $("#phone").val(),
		address: $("#address").val(),
		province: $("#province").val(),
		city: $("#city").val(),
		flag: "0",
		area: $("#area").val(),
		orgType: $("#org option:selected").val(),
	}
	$.ajax({
		url: 'orgOperation',
		type: 'POST',
		data: param,
		dataType: 'json',
		success: function(data) {
			if(data.errorCode == -303) {
				alert("机构不存在！")
			} else if(data.errorCode == -6) {
				alert("登陆超时！")
				top.location.href = 'index.jsp';

			} else if(data.errorCode == 0) {
				parent.location.href = 'userInstitution.jsp';

			}

		},
		error: function(err) {
			alert("连接服务器失败！请重新提交！")
			top.location.href = 'index.jsp';

		}
	});

}